<script>
    $(document).ready(function($) {
        $(".cb-enable").click(function(){
            var parent = $(this).parents('.switch');
            $('.cb-disable',parent).removeClass('selected');
            $(this).addClass('selected');
            $('.checkbox',parent).attr('checked', true);
        });

        $(".cb-disable").click(function(){
            var parent = $(this).parents('.switch');
            $('.cb-enable',parent).removeClass('selected');
            $(this).addClass('selected');
            $('.checkbox',parent).attr('checked', false);
        });

        var startDateTextBox = $('#notice_start_date');
        var endDateTextBox = $('#notice_end_date');

        startDateTextBox.datetimepicker({
            dateFormat: 'yy-mm-dd',
            timeFormat: 'HH:mm',
            stepHour: 1,
            stepMinute: 1,
            onClose: function(dateText, inst) {
                if (endDateTextBox.val() != '') {
                    var testStartDate = startDateTextBox.datetimepicker('getDate');
                    var testEndDate = endDateTextBox.datetimepicker('getDate');
                    if (testStartDate > testEndDate)
                        endDateTextBox.datetimepicker('setDate', testStartDate);
                }
                else {
                    endDateTextBox.val(dateText);
                }
            },
            onSelect: function (selectedDateTime){
                endDateTextBox.datetimepicker('option', 'minDate', startDateTextBox.datetimepicker('getDate') );
            }
        });
        endDateTextBox.datetimepicker({
            dateFormat: 'yy-mm-dd',
            timeFormat: 'HH:mm',
            stepHour: 1,
            stepMinute: 1,
            onClose: function(dateText, inst) {
                if (startDateTextBox.val() != '') {
                    var testStartDate = startDateTextBox.datetimepicker('getDate');
                    var testEndDate = endDateTextBox.datetimepicker('getDate');
                    if (testStartDate > testEndDate)
                        startDateTextBox.datetimepicker('setDate', testEndDate);
                }
                else {
                    startDateTextBox.val(dateText);
                }
            },
            onSelect: function (selectedDateTime){
                startDateTextBox.datetimepicker('option', 'maxDate', endDateTextBox.datetimepicker('getDate') );
            }
        });

    });
</script>

<div class="tales_stats_menu">
    <ui>
        <li class="tales_of_deonia"><?php echo __(LANG_TALES_OF_DEONIA)?></li>
    </ui>
</div>

<!-- Etc 메뉴 -->
<div class="tales_stats_menu">
    <ul>
        <li class="actions">
            <?php echo $this->Html->link(__('Event'), array('action' => 'event_setting'));?>
        </li>
        <li class="actions">
            <?php echo $this->Html->link(__('Server'), array('action' => 'system_setting'));?>
        </li>
    </ul>
</div>

<div class="system_main">
    <div class="system_main_one">
        <div>
            <?php echo $this->Form->create('system_setting');?>
            <?php echo $this->Form->hidden('num', array(
                'label' => false,
                'value' => $server['tbl_system_notice']['num']
            ));?>
        </div>
        <div class="div_title"><?php echo __('System Setting')?></div>
        <table border="0">
            <!--<tr>
                <th class="user" style="width: 120px"><?php /*echo __('Server Status')*/?></th>
                <td class="background_white" style="padding-right: 19px; font-size: 11px">
                    <div class="field switch">
                        <?php /*if($server['tbl_system_notice']['server_status'] == 0) {*/?>
                            <label class="cb-enable selected" for="typeOn1"><span>On</span></label>
                            <label class="cb-disable" for="typeOff1"><span>Off</span></label>
                        <?php /*} else { */?>
                            <label class="cb-enable" for="typeOn1"><span>On</span></label>
                            <label class="cb-disable selected" for="typeOff1"><span>Off</span></label>
                        <?php /*}*/?>
                        <input type="radio" name="data[system_setting][server_status]" id="typeOn1" value="0" />
                        <input type="radio" name="data[system_setting][server_status]" id="typeOff1" value="1" />
                    </div>
                </td>
            </tr>-->
            <tr>
                <th class="user"><?php echo __('Notice IMG URL')?></th>
                <td class="background_white" style="padding-right: 19px">
                    <?php echo $this->Form->input('url', array(
                        'label' => false,
                        'type' => 'text',
                        'placeholder' => 'http://',
                        'value' => $server['tbl_system_notice']['url'],
                    ));?>
                </td>
            </tr>
            <tr>
                <th class="user"><?php echo __('IMG Link URL')?></th>
                <td class="background_white" style="padding-right: 19px">
                    <?php echo $this->Form->input('link_url', array(
                        'label' => false,
                        'type' => 'text',
                        'placeholder' => 'http://',
                        'value' => empty($server['tbl_system_notice']['link_url']) ? '' : $server['tbl_system_notice']['link_url'],
                    ));?>
                </td>
            </tr>
            <tr>
                <th class="user"><?php echo __('Notice Start')?></th>
                <td class="background_white" style="padding-right: 19px">
                    <?php echo $this->Form->input('start_date', array(
                        'label' => false,
                        'type' => 'text',
                        'id' => 'notice_start_date',
                        'value' => $server['tbl_system_notice']['start_date'],
                    ));?>
                </td>
            </tr>
            <tr>
                <th class="user"><?php echo __('Notice End')?></th>
                <td class="background_white" style="padding-right: 19px">
                    <?php echo $this->Form->input('end_date', array(
                        'label' => false,
                        'type' => 'text',
                        'id' => 'notice_end_date',
                        'value' => $server['tbl_system_notice']['end_date'],
                    ));?>
                </td>
            </tr>
        </table>
        <table>
            <tr>
                <td class="message_box no_border">
                    <?php if(!empty($err_msg)) {?>
                        <p class="error_message"><?php echo $err_msg?></p>
                    <?php } else  if(!empty($sus_msg)){?>
                        <p class="success_message"><?php echo $sus_msg?></p>
                    <?php }?>
                </td>
                <td class="no_border" style="text-align: right">
                    <?php echo $this->Form->end(__(LANG_SEND));?>
                </td>
            </tr>
        </table>
    </div>
</div>